package org.colafries.admin.controller.index;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.colafries.admin.entity.domain.index.LogicFactTable;
import org.colafries.admin.entity.vo.index.LogicFactTblReqVO;
import org.colafries.admin.service.index.ILogicFactTableService;
import org.colafries.admin.wrapper.Response;
import org.colafries.admin.wrapper.ResponseWrapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Ann
 * @version v1.0
 * @ClassName LogicFactTableController
 * @Description
 * @date Created in 2024/6/3
 **/
@RestController
@RequestMapping("/index/logicFactTable")
public class LogicFactTableController {

    @Resource
    ILogicFactTableService logicFactTableService;

    /**
     * 新增逻辑事实表
     *
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/3
     */
    @PostMapping("/add")
    public Response<?> add(@RequestBody LogicFactTblReqVO reqVO) {
        int result = logicFactTableService.add(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 修改逻辑事实表
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/5
     */
    @PostMapping("/update")
    public Response<?> update(@RequestBody LogicFactTblReqVO reqVO) {
        int result = logicFactTableService.update(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 删除逻辑事实表
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/5
     */
    @PostMapping("/delete")
    public Response<?> delete(@RequestBody LogicFactTblReqVO reqVO) {
        int result = logicFactTableService.delete(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 查询所有逻辑事实表list
     *
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/3
     */
    @PostMapping("/listAll")
    public Response<?> listAll(@RequestBody LogicFactTblReqVO reqVO) {
        List<LogicFactTable> result = logicFactTableService.listAll(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 分页查询逻辑事实表
     *
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/3
     */
    @PostMapping("/pageList")
    public Response<?> pageList(@RequestBody LogicFactTblReqVO reqVO) {
        IPage<LogicFactTable> result = logicFactTableService.pageList(reqVO);
        return ResponseWrapper.ok(result);
    }
}
